var TRE_FEE_DETAIL_PATH = "";
var TRE_FEE_TYPE_PATH = "";
var isExist = false;
var feeType = "";

// 浮动费率
var $gridparents = null;
var $feeChangeList = null;

// 浮动收益率
var $floatYieldFeeRateType = null;
var $yieldFeeChangeList = null;


function setPathPrefix(treFeeDetailPath,treFeeTypePath) {
	TRE_FEE_DETAIL_PATH = treFeeDetailPath;
	TRE_FEE_TYPE_PATH = treFeeTypePath;
}
var TRE_FEE_DETAIL = function(){
	this.init();
};
/**
 * 初始化方法
 */
TRE_FEE_DETAIL.prototype.init = function(){
	
	var self = this;
	self.expand();
	self.feeChangeListInit();
	self.yieldFeeChangeListInit();
	
	// 给select2组件加载样式
	WASP_WIDGET.initializeSelectStyle();
	// 加载日期控件
	WASP_WIDGET.triggerDateStyleWithYMD("#feeBeginDate");
	WASP_WIDGET.triggerDateStyleWithYMD("#feeEndDate");
	WASP_WIDGET.triggerDateStyleWithYMD("#feePayDateFirst");
	WASP_WIDGET.triggerDateStyleWithYMD("#rateBeginDate");
	WASP_WIDGET.triggerDateStyleWithYMD("#rateEndDate");
	
	WASP_WIDGET.triggerDateStyleWithYMD("#yieldInteBgnDate");
	WASP_WIDGET.triggerDateStyleWithYMD("#yieldInteEndDate");
	WASP_WIDGET.triggerDateStyleWithYMD("#interestPayDateFirst");
	WASP_WIDGET.triggerDateStyleWithYMD("#yieldBeginDate");
	WASP_WIDGET.triggerDateStyleWithYMD("#yieldEndDate");
	
	self.selectFeeCode();
	
	var type = $("#type").val();
	if (type == 'cpyy') {
		WASP_WIDGET.triggerSubProductInfoSelect("subPrdCode");
	} else {
		WASP_WIDGET.triggerSubProductInfoSelect("subPrdCode", null, {"url": "queryMatchSubPrdLineList.do"});
	}
	
	
}
/**
 * 拓展方法
 */
TRE_FEE_DETAIL.prototype.expand = function(){
	var self = this;

	self.addTreFeeDetail = function() {
		SubmitAndPreventSecond("treFeeDetailAddForm",function() {
			if(!$("form[name='treFeeDetailAddForm']").valid()) {
				toastr.warning('', '请完善信息');
				return false;
			}
			debugger;
			console.log(self.checkInfo());
			if(!self.checkInfo()){
				return false;
			}
			// 浮动费率必填校验
			if('fee' == feeType){
				var feeRateType = $("#feeRateType").val();
				if (feeRateType == '1') {
					var changeFeeList = $feeChangeList.jqGrid("getRowData");
					if (changeFeeList && changeFeeList.length > 0) {
						for (var i = 0; i < changeFeeList.length; i++) {
							var changeFee = changeFeeList[i];
							var rateBeginDateId = $(changeFee.rateBeginDate).attr("id");
							var rateEndDateId = $(changeFee.rateEndDate).attr("id");
							var changeFeeRateId = $(changeFee.changeFeeRate).attr("id");

							changeFee.rateBeginDate = $("#" + rateBeginDateId).val();
							changeFee.rateEndDate = $("#" + rateEndDateId).val();
							changeFee.changeFeeRate = $("#" + changeFeeRateId).val();
							delete changeFee.option;// 操作按钮不提交

							if (!changeFee.rateBeginDate) {
								toastr.warning('', '请录入浮动费率起期');
								return false;
							}

							if (!changeFee.rateEndDate) {
								toastr.warning('', '请录入浮动费率止期');
								return false;
							}

							if (!changeFee.changeFeeRate) {
								toastr.warning('', '请录入浮动费率值');
								return false;
							}
						}
						$("#feeChangeListJson").val(JSON.stringify(changeFeeList));
					} else {
						toastr.warning('', '请录入浮动费率');
						return false;
					}
				}
			}else{
				var yieldType = $("#yieldType").val();
				if (yieldType == '1') {
					var yieldFeeChangeList = $yieldFeeChangeList.jqGrid("getRowData");
					if (yieldFeeChangeList && yieldFeeChangeList.length > 0) {
						for (var i = 0; i < yieldFeeChangeList.length; i++) {
							var changeYield = yieldFeeChangeList[i];
							var yieldBeginDateId = $(changeYield.yieldBeginDate).attr("id");
							var yieldEndDateId = $(changeYield.yieldEndDate).attr("id");
							var yieldRateId = $(changeYield.yieldRate).attr("id");

							changeYield.yieldBeginDate = $("#" + yieldBeginDateId).val();
							changeYield.yieldEndDate = $("#" + yieldEndDateId).val();
							changeYield.yieldRate = $("#" + yieldRateId).val();
							delete changeYield.option;// 操作按钮不提交

							if (!changeYield.yieldBeginDate) {
								toastr.warning('', '请录入浮动费率起期');
								return false;
							}

							if (!changeYield.yieldEndDate) {
								toastr.warning('', '请录入浮动费率止期');
								return false;
							}

							if (!changeYield.yieldRate) {
								toastr.warning('', '请录入浮动费率值');
								return false;
							}
						}
						$("#yieldChangeListJson").val(JSON.stringify(yieldFeeChangeList));
					} else {
						toastr.warning('', '请录入浮动费率');
						return false;
					}
				}
			}
			var type = $("#type").val();
			if (type == 'cpyy') {
				$("#treFeeDetailAddForm").attr("action", prdFeePath + "savePrdFeeDetail.do");
			}
			return true;
		}, true);
	};
	//加载费用类型列表
	self.selectFeeCode =  function(){
		var actionUrl = TRE_FEE_TYPE_PATH + "treFeeTypeList.do";
		var type = $("#type").val();
		if (type == 'cpyy') {
			actionUrl =  prdFeePath + "feeTypeList.do";
		}
		$.ajax({
			type : "POST",
			url : actionUrl,
			dataType : "json",
			success : function(data){
				if(data){
					data = JSON.parse(data);
					$.each(data, function (index, item) {
						$("#feeCode").append("<option value='"+item.feeCode+"'>"+item.feeName+"</option>");
				    });
				}else{

				}
			},
			error : function(e) {
				toastr.error(e,"系统出现异常！");
			},
		});
	};

	//选择费用类型
	self.customAddFee =  function(){
		$('*[name="show_custom_fee"]').show();

		var feeName = $("#feeCode").find("option:selected").text();
		$('*[name="show_custom_fee_title"]').html(feeName);

		$('*[name="feeName"]').val(feeName);

	};

	//费用或收益
	self.chooseFeeType =  function(elem){
		debugger;
		$("#customType").show();
		$('*[name="fee_type"]').each(function(index,element){
	    	$(element).removeClass('checked');
	    });
		$(elem).addClass('checked');
		var data = '';
		$('*[name="fee_type"].checked').each(function(index,element){
			data += $(element).attr("value");
		});
		if(data.length > 0){
			if(data == 'fee'){
				$('#treFeeDetailAddForm').attr('action', TRE_FEE_DETAIL_PATH + "saveTreFeeDetail.do");
				$("#yieldContainer :input").attr("disabled", "disabled");
				$("#feeContainer :input").removeAttr("disabled");

				$('*[name="customTypeTitle"]').html("费用类型<span class='text-danger'>*</span>");
				$('*[name="custom_fee"]').show();
				$('*[name="custom_yield"]').hide();
				$('*[name="show_custom_yield"]').hide();
				feeType = "fee";
			}else if(data == 'yield'){
				$('#treFeeDetailAddForm').attr('action', TRE_FEE_DETAIL_PATH + "saveTreYieldDetail.do");
				$("#feeContainer :input").attr("disabled", "disabled");
				$("#yieldContainer :input").removeAttr("disabled");

				$('*[name="custom_fee"]').hide();
				$('*[name="customTypeTitle"]').html("收益类型");
				$('*[name="show_custom_fee"]').hide();
				$('*[name="show_custom_yield"]').show();
				$('*[name="custom_yield"]').show();
				$('#feeCode').val("");
				feeType = "yield";
			}
			$("#feeType").val(feeType);
		}
	};

	// 选择计费结束日期时，给首次支付日和天数文本框赋值
	self.selectFeeBeginOrEndDate =  function(elem){
		debugger;
		var data = '';
		//判断是费率还是收益
		var elemName = $(elem).attr("name");
		if('feeIsCalEndDayAmount' == elemName || 'feeBeginDate' == elemName ||  'feeEndDate' == elemName){
			if('feeIsCalEndDayAmount' == elemName){
				$('*[name="feeIsCalEndDayAmount"]').each(function(index,element){
					$(element).removeClass('checked');
				});
				$(elem).addClass('checked');
			}
			$('*[name="feeIsCalEndDayAmount"].checked').each(function(index,element){
				data += $(element).attr("value");
				$("#isCalEndDayAmount").val(data);
			});
			//计费起始日-计费结束日
			var feeBeginDate = $.trim($("#feeBeginDate").val());
			var feeEndDate = $.trim($("#feeEndDate").val());

			if(feeBeginDate && feeEndDate){
				if(!moment(feeBeginDate).isBefore(feeEndDate)){
					toastr.warning('', '计费开始日不能大于或等于计费结束日');
					return;
				}
				var days = moment(feeEndDate).diff(feeBeginDate, 'days');
				//天数
				if('Y'==data){
					$("#payDeviationDay").val(days+1);
				}else{
					$("#payDeviationDay").val(days);
				}
			}
			//首次支付日
			if(feeEndDate){
				$("#feePayDateFirst").val(feeEndDate);
			}
		}else{
			debugger;
			if('yieldIsCalEndDayAmount' == elemName){
				$('*[name="yieldIsCalEndDayAmount"]').each(function(index,element){
					$(element).removeClass('checked');
				});
				$(elem).addClass('checked');
			}
			$('*[name="yieldIsCalEndDayAmount"].checked').each(function(index,element){
				data += $(element).attr("value");
				$("#yIsCalEndDayAmount").val(data);
			});
			//计费起始日-计费结束日
			var yieldInteBgnDate = $.trim($("#yieldInteBgnDate").val());
			var yieldInteEndDate = $.trim($("#yieldInteEndDate").val());

			if(yieldInteBgnDate && yieldInteEndDate){
				if(!moment(yieldInteBgnDate).isBefore(yieldInteEndDate)){
					toastr.warning('', '计费开始日不能大于计费结束日');
					return;
				}
				var days = moment(yieldInteEndDate).diff(yieldInteBgnDate, 'days');
				//天数
				if('Y'==data){
					$("#yield_payDeviationDay").val(days+1);
				}else{
					$("#yield_payDeviationDay").val(days);
				}
			}
			//首次支付日
			if(yieldInteEndDate){
				$("#interestPayDateFirst").val(yieldInteEndDate);
			}
		}
	};

	//选中浮动费率时，显示
	self.selectFeeRateType = function(){
//		1.固定费率： 费率必填 、费用总金额只读
//		2.浮动费率：费率必填、 添加费率变动列表
//		3.固定金额： 费率只读、 计费本金只读、 费用总金额必填
//		4.剩余费用： 费率只读、 计费本金只读、 费用总金额只读
		var feeRateType = $("#feeRateType").val();
		if('0' == feeRateType){
			//费率
			$("#feeRate_span").show();
			$("#feeRate").removeAttr("readonly");
			//费用总金额
			$("#feeAggregateAmouunt_span").hide();
			$("#feeAggregateAmouunt").attr("readonly","readonly");
			//计费本金
			$("#feePrincipal_span").show();
			$("#feePrincipal").removeAttr("readonly");
			//浮动费率，浮动列表
			$("#floatFeeRate").hide();
		} else if('1' == feeRateType){
			//费率
			$("#feeRate_span").show();
			$("#feeRate").removeAttr("readonly");
			//费用总金额
			$("#feeAggregateAmouunt_span").hide();
			$("#feeAggregateAmouunt").attr("readonly","readonly");
			//计费本金
			$("#feePrincipal_span").show();
			$("#feePrincipal").removeAttr("readonly");
			//浮动费率，浮动列表
			$("#floatFeeRate").show();
			jqGridResize($feeChangeList, $gridparents);
		}else if('2' == feeRateType){
			//费率
			$("#feeRate_span").hide();
			$("#feeRate").attr("readonly","readonly");
			//费用总金额
			$("#feeAggregateAmouunt_span").show();
			$("#feeAggregateAmouunt").removeAttr("readonly");
			//计费本金
			$("#feePrincipal_span").hide();
			$("#feePrincipal").attr("readonly","readonly");
			//浮动费率，浮动列表
			$("#floatFeeRate").hide();
		}else{
			//费率
			$("#feeRate_span").hide();
			$("#feeRate").attr("readonly","readonly");
			//费用总金额
			$("#feeAggregateAmouunt_span").hide();
			$("#feeAggregateAmouunt").attr("readonly","readonly");
			//计费本金
			$("#feePrincipal_span").hide();
			$("#feePrincipal").attr("readonly","readonly");
			//浮动费率，浮动列表
			$("#floatFeeRate").hide();
		}
	}

	// 浮动费率列表初始化
	self.feeChangeListInit = function() {
		$gridparents = $("#floatFeeRateType");
		$feeChangeList = $("#feeChangeList");

		$feeChangeList.jqGrid({
			url: "",
	        datatype: "local",
	        colNames: ["ID", "起期", "止期", "费率(%)",'操作'],
	        colModel: [
	            { name: 'id', index: 'id', hidden: true, key: true },
	            { name: 'rateBeginDate', index: 'rateBeginDate', width: 60, resizable: true, sortable: false, editable: true,
	            	edittype:"text",
						editoptions:{
						size: 10,
						maxlengh: 10,
						readOnly:true,
						dataInit: function(element) {
							WASP_WIDGET.triggerDateStyleWithYMD(element);
	  					}
					}
	            },
	            { name: 'rateEndDate', index: 'rateEndDate', width: 60, resizable: true, sortable: false, editable: true,
	            	edittype:"text",
						editoptions:{
						size: 10,
						maxlengh: 10,
						readOnly:true,
						dataInit: function(element) {
							WASP_WIDGET.triggerDateStyleWithYMD(element);
	  					}
					}
	            },
	            { name: 'changeFeeRate', index: 'changeFeeRate', width: 30, resizable: true, sortable: false, editable: true,
				 	editoptions: {
				 		dataEvents:[{
				  			type: 'blur',
				  			fn: function(e) {
				  				fmtNum136(this);
				  			}
				  		}]
				  	}
	            },
	            { name: 'option', index: 'option', width: 20, resizable: true, sortable: false }
	        ],
	        rowNum: 10,
	        rowList: [10, 30, 50],
	        rownumbers: true,
	        rownumWidth: 50,
	        postData:{
			 	'sp[parentId]':'0'
				},
	        prmNames: {
	        	        search: "search",
	        	        page: "pageNo",
	        	        rows: "limit"
	        	       },
	        height: 'auto',
	        width: false,
	        autowidth:true,
	        shrinkToFit:true,
	        editurl: '',
	        viewrecords: true,
	        cellEdit: false,
	        shrinkToFit: true,
	        grouping: false,
	        jsonReader: {
	            root: "items", //结果集
	            records: "total", //总记录数
	            total: "pageCount", //总页数
	            page: "pageNo", //当前页
	            repeatitems: false // (4)
	        },
	        multiselect: false,
	        pager: "#feeChangeListPage",
	        viewrecords: true,
	        hidegrid: false,
			gridComplete: function() {
				var feeIds = jQuery("#feeChangeList").jqGrid('getDataIDs');
				for(var i = 0; i < feeIds.length; i++){
					var feeId = feeIds[i];
					$feeChangeList.editRow(feeId);
	                // 添加删除按钮
	                var  deleteBtn = '<a href="javascript:void(0);" class="btn btn-link btn-jqgrid" title="删除" onclick="treFeeDetail.deleteChangeFee(\''+feeId+'\');">删除</a>';
	                $feeChangeList.jqGrid('setRowData', feeId, { option: deleteBtn });
				}
			}
		});
		$feeChangeList.navGrid('#feeChangeListPage',{edit:false,add:false,del:false,search:false,refresh:false})
		.navButtonAdd('#feeChangeListPage',{
			id: "feeChangeListPageAdd",
			caption:"新增",
			buttonicon:"ui-icon-plus",
			position:"last",
			onClickButton: function(){
				self.addFeeRateList();
			}
		});;
		$feeChangeList.jqGrid('setFrozenColumns');
		jqGridResize($feeChangeList, $gridparents);
	}

	// 添加浮动费率行
	self.addFeeRateList = function() {
		var feeRateNewRowId = new Date().getTime();
		var dataRow = {
			id : feeRateNewRowId
		};
		$feeChangeList.jqGrid("addRowData", feeRateNewRowId, dataRow, "last");
	}

	// 删除浮动费率
	self.deleteChangeFee = function(feeId) {
		$feeChangeList.jqGrid("delRowData", feeId);
	}

	//选中浮动收益率时，显示
	self.selectYieldRateType = function(){

		var yieldType = $("#yieldType").val();

		if('0' == yieldType){
			//费率
			$("#yield_span").show();
			$("#yield").removeAttr("readonly");
			//费用总金额
			$("#yieldAggregateAmouunt_span").hide();
			$("#yieldAggregateAmouunt").attr("readonly","readonly");
			//计费本金
			$("#interestPrincipal_span").show();
			$("#interestPrincipal").removeAttr("readonly");
			//浮动费率，浮动列表
			$("#floatYieldRate").hide();
			$("#floatYieldRate :input").attr("disabled", "disabled");
		} else if('1' == yieldType){
			//费率
			$("#yield_span").show();
			$("#yield").removeAttr("readonly");
			//费用总金额
			$("#yieldAggregateAmouunt_span").hide();
			$("#yieldAggregateAmouunt").attr("readonly","readonly");
			//计费本金
			$("#interestPrincipal_span").show();
			$("#interestPrincipal").removeAttr("readonly");
			//浮动费率，浮动列表
			$("#floatYieldRate").show();
			jqGridResize($yieldFeeChangeList, $floatYieldFeeRateType);
		}else if('2' == yieldType){
			//费率
			$("#yield_span").hide();
			$("#yield").attr("readonly","readonly");
			//费用总金额
			$("#yieldAggregateAmouunt_span").show();
			$("#yieldAggregateAmouunt").removeAttr("readonly");
			//计费本金
			$("#interestPrincipal_span").hide();
			$("#interestPrincipal").attr("readonly","readonly");
			//浮动费率，浮动列表
			$("#floatYieldRate").hide();
			$("#floatYieldRate :input").attr("disabled", "disabled");
		}else{
			//业绩比较基准
			$("#yield_span").hide();
			$("#yield").attr("readonly","readonly");
			//费用总金额
			$("#yieldAggregateAmouunt_span").hide();
			$("#yieldAggregateAmouunt").attr("readonly","readonly");
			//计费本金
			$("#interestPrincipal_span").hide();
			$("#interestPrincipal").attr("readonly","readonly");
			//浮动费率，浮动列表
			$("#floatYieldRate").hide();
			$("#floatYieldRate :input").attr("disabled", "disabled");
		}

	}

	// 浮动收益率列表初始化
	self.yieldFeeChangeListInit = function() {
		$floatYieldFeeRateType = $("#floatYieldFeeRateType");
		$yieldFeeChangeList = $("#yieldFeeChangeList");

		$yieldFeeChangeList.jqGrid({
			url: "",
	        datatype: "local",
	        colNames: ["ID", "起期", "止期", "费率(%)",'操作'],
	        colModel: [
	            { name: 'id', index: 'id', hidden: true, key: true },
	            { name: 'yieldBeginDate', index: 'yieldBeginDate', width: 60, resizable: true, sortable: false, editable: true,
	            	edittype:"text",
						editoptions:{
						size: 10,
						maxlengh: 10,
						readOnly:true,
						dataInit: function(element) {
							WASP_WIDGET.triggerDateStyleWithYMD(element);
	  					}
					}
	            },
	            { name: 'yieldEndDate', index: 'yieldEndDate', width: 60, resizable: true, sortable: false, editable: true,
	            	edittype:"text",
						editoptions:{
						size: 10,
						maxlengh: 10,
						readOnly:true,
						dataInit: function(element) {
							WASP_WIDGET.triggerDateStyleWithYMD(element);
	  					}
					}
	            },
	            { name: 'yieldRate', index: 'yieldRate', width: 30, resizable: true, sortable: false, editable: true,
				 	editoptions: {
				 		dataEvents:[{
				  			type: 'blur',
				  			fn: function(e) {
				  				fmtNum136(this);
				  			}
				  		}]
				  	}
	            },
	            { name: 'option', index: 'option', width: 20, resizable: true, sortable: false }
	        ],
	        rowNum: 10,
	        rowList: [10, 30, 50],
	        rownumbers: true,
	        rownumWidth: 50,
	        postData:{
			 	'sp[parentId]':'0'
				},
	        prmNames: {
	        	        search: "search",
	        	        page: "pageNo",
	        	        rows: "limit"
	        	       },
	        height: 'auto',
	        width: false,
	        autowidth:true,
	        shrinkToFit:true,
	        editurl: '',
	        viewrecords: true,
	        cellEdit: false,
	        shrinkToFit: true,
	        grouping: false,
	        jsonReader: {
	            root: "items", //结果集
	            records: "total", //总记录数
	            total: "pageCount", //总页数
	            page: "pageNo", //当前页
	            repeatitems: false // (4)
	        },
	        multiselect: false,
	        pager: "#yieldFeeChangeListPage",
	        viewrecords: true,
	        hidegrid: false,
			gridComplete: function() {
				var feeIds = jQuery("#yieldFeeChangeList").jqGrid('getDataIDs');
				for(var i = 0; i < feeIds.length; i++){
					var feeId = feeIds[i];
					$yieldFeeChangeList.editRow(feeId);
	                // 添加删除按钮
	                var  deleteBtn = '<a href="javascript:void(0);" class="btn btn-link btn-jqgrid" title="删除" onclick="treFeeDetail.deleteYieldChangeFee(\''+feeId+'\');">删除</a>';
	                $yieldFeeChangeList.jqGrid('setRowData', feeId, { option: deleteBtn });
				}
			}
		});
		$yieldFeeChangeList.navGrid('#yieldFeeChangeListPage',{edit:false,add:false,del:false,search:false,refresh:false})
		.navButtonAdd('#yieldFeeChangeListPage',{
			id: "yieldFeeChangeListPageAdd",
			caption:"新增",
			buttonicon:"ui-icon-plus",
			position:"last",
			onClickButton: function(){
				self.addYieldFeeRateList();
			}
		});
		$yieldFeeChangeList.jqGrid('setFrozenColumns');
		jqGridResize($yieldFeeChangeList, $floatYieldFeeRateType);
	}

	// 添加浮动费率行
	self.addYieldFeeRateList = function() {
		var feeRateNewRowId = new Date().getTime();
		var dataRow = {
			id : feeRateNewRowId
		};
		$yieldFeeChangeList.jqGrid("addRowData", feeRateNewRowId, dataRow, "last");
	}


	// 删除浮动收益率
	self.deleteYieldChangeFee = function(feeId) {
		$yieldFeeChangeList.jqGrid("delRowData", feeId);
	}
	//校验必填字段
	self.checkInfo = function(){
//		1.固定费率： 费率必填 、费用总金额只读
//		2.浮动费率：费率必填、 添加费率变动列表
//		3.固定金额： 费率只读、 计费本金只读、 费用总金额必填
//		4.剩余费用： 费率只读、 计费本金只读、 费用总金额只读
		
//		固定必填字段： 费用名称、费用类型、 年计算天数、 计费起始日、 计费结束日、 付费频率、 首次支付日、 费率类型
		var subPrdCode = $("#subPrdCode").val();
		
		if(!$.trim(subPrdCode)){
			toastr.warning('', '产品简称不能为空');
			return;
		}
		
		if(!$.trim(feeType)){
			toastr.warning('', '费用或收益不能为空');
			return;
		}

		//根据不同的类型做相应的校验
		if('fee' == feeType){
			var feeCode = $("#feeCode").val();
			var feeName = $("#feeName").val();
			var feeDaysOfYear = $("#feeDaysOfYear").val();
			var feeBeginDate = $("#feeBeginDate").val();
			var feeEndDate = $("#feeEndDate").val();
			var feeFrequency = $("#feeFrequency").val();
			var feePayDateFirst = $("#feePayDateFirst").val();
			var feeRateType = $("#feeRateType").val();
			
			var feeRate = $("#feeRate").val();//费率
			var feePrincipal = $("#feePrincipal").val();//计费本金
			var feeAggregateAmouunt = $("#feeAggregateAmouunt").val();//费用总金额
			
			if(!$.trim(feeCode)){
				toastr.warning('', '费用类型不能为空');
				return;
			}
			if(!$.trim(feeName)){
				toastr.warning('', '费用名称不能为空');
				return;
			}
			if(!$.trim(feeRateType)){
				toastr.warning('', '费率类型不能为空');
				return;
			}
			
			if('0' == feeRateType || '1' == feeRateType){//固定费率： 费率必填 、费用总金额只读   ||　浮动费率：费率必填、 添加费率变动列表
				if(!$.trim(feeRate)){
					toastr.warning('', '费率不能为空');
					return;
				}
				
				if(!$.trim(feePrincipal)){
					toastr.warning('', '计费本金不能为空');
					return;
				}
			}
			if(!$.trim(feeDaysOfYear)){
				toastr.warning('', '年计算天数不能为空');
				return;
			}
			if(!$.trim(feeBeginDate)){
				toastr.warning('', '计费起始日不能为空');
				return;
			}
			if(!$.trim(feeEndDate)){
				toastr.warning('', '计费结束日不能为空');
				return;
			}
			if(!$.trim(feeFrequency)){
				toastr.warning('', '付费频率不能为空');
				return;
			}
			if(!$.trim(feePayDateFirst)){
				toastr.warning('', '首次支付日不能为空');
				return;
			}
			if('2' == feeRateType){//固定金额： 费率只读、 计费本金只读、 费用总金额必填
				if(!$.trim(feeAggregateAmouunt)){
					toastr.warning('', '费用总金额不能为空');
					return;
				}
			}
		}else{
			var yieldName = $("#yieldName").val();
			var calDaysOfYear = $("#calDaysOfYear").val();
			var yieldInteBgnDate = $("#yieldInteBgnDate").val();
			var yieldInteEndDate = $("#yieldInteEndDate").val();
			var yieldPayRate = $("#yieldPayRate").val();
			var interestPayDateFirst = $("#interestPayDateFirst").val();
			var yieldType = $("#yieldType").val();
			
			var yieldRate = $("#yield").val();//费率
			var interestPrincipal = $("#interestPrincipal").val();//计息本金
			var yieldAggregateAmouunt = $("#yieldAggregateAmouunt").val();//收益总金额
			
			if(!$.trim(yieldName)){
				toastr.warning('', '收益名称不能为空');
				return;
			}
			if(!$.trim(yieldType)){
				toastr.warning('', '业绩比较基准类型不能为空');
				return;
			}
			
			if('0' == yieldType || '1' == yieldType){//固定费率： 费率必填 、费用总金额只读   ||　浮动费率：费率必填、 添加费率变动列表
				if(!$.trim(yieldRate)){
					toastr.warning('', '业绩比较基准不能为空');
					return;
				}
				
				if(!$.trim(interestPrincipal)){
					toastr.warning('', '计息本金不能为空');
					return;
				}
			}
			if(!$.trim(calDaysOfYear)){
				toastr.warning('', '年计算天数不能为空');
				return;
			}
			if(!$.trim(yieldInteBgnDate)){
				toastr.warning('', '计费起始日不能为空');
				return;
			}
			if(!$.trim(yieldInteEndDate)){
				toastr.warning('', '计费结束日不能为空');
				return;
			}
			if(!$.trim(yieldPayRate)){
				toastr.warning('', '分配频率不能为空');
				return;
			}
			if(!$.trim(interestPayDateFirst)){
				toastr.warning('', '首次支付日不能为空');
				return;
			}
			if('2' == yieldType){//固定金额： 费率只读、 计费本金只读、 费用总金额必填
				if(!$.trim(yieldAggregateAmouunt)){
					toastr.warning('', '收益总金额不能为空');
					return;
				}
			}
		}
		return true;
	}
}
